//webpack.config.js文件
const path = require("path");
//导入html插件得到构造函数
const HtmlPlugin = require("html-webpack-plugin");
//创建一个html插件实例对象
const htmlPlugin = new HtmlPlugin({
    template: "./src/index.html", //指定原文件存放的路劲
    filename: "./index.html", //指定生成的文件存放路径
});
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
const clean = new CleanWebpackPlugin();
module.exports = {
    mode: "development", //production
    devtool: "nosources-source-map",
    //插件的数组,将来webpack 在运行时,会加载并调用这些插件
    plugins: [htmlPlugin, clean], //通过plugins节点使htmlPlugin插件生效
    //******************
    // entry:'指定要处理的文件'
    devServer: {
        open: true,
        host: "127.0.0.1",
        port: 80,
    },
    entry: path.join(__dirname, "./src/index1.js"),
    //output:'指定打包出口'
    output: {
        path: path.join(__dirname, "dist"),
        filename: "js/bundle.js",
    },
    module: {
        //所有第三方文件模块匹配规则
        rules: [
            //文件后缀名匹配规则
            { test: /\.css/, use: ["style-loader", "css-loader", "less-loader"] },
            { test: /\.less/, use: ["style-loader", "css-loader", "less-loader"] },
            { test: /\.jpg|png|gif$/, use: "url-loader?limit=10&outputPath=images" },
            { test: /\.js$/, use: "babel-loader", exclude: /node_modules/ },
        ],
    },
    resolve: {
        // 指定文件查询为@往下找
        alias: {
            "@": path.join(__dirname, "./src/"),
        },
    },
};